//package com.xc.hotelmgr.consumermq.config;
//
//import com.rabbitmq.client.AMQP;
//import com.rabbitmq.client.Channel;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.rabbit.core.ChannelCallback;
//import org.springframework.amqp.rabbit.core.RabbitAdmin;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.Scheduled;
//
//@Slf4j
//@Configuration
//public class Scheduling {
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    @Autowired
//    private RabbitAdmin rabbitAdmin;
//
////    @Scheduled(fixedRate=60000)
//    private void configureTasks() {
//        String queue1 = "change_rates";
//        String queue2 = "callback_rates_28079763";
//        AMQP.Queue.DeclareOk declareOk1 = rabbitTemplate.execute(new ChannelCallback<AMQP.Queue.DeclareOk>() {
//            public AMQP.Queue.DeclareOk doInRabbit(Channel channel) throws Exception {
//                return channel.queueDeclarePassive(queue1);
//            }
//        });
//        AMQP.Queue.DeclareOk declareOk2 = rabbitTemplate.execute(new ChannelCallback<AMQP.Queue.DeclareOk>() {
//            public AMQP.Queue.DeclareOk doInRabbit(Channel channel) throws Exception {
//                return channel.queueDeclarePassive(queue1);
//            }
//        });
//        int change_rates_num = declareOk1.getMessageCount();
//        int callback_rates_28079763_num = declareOk2.getMessageCount();
//        if(change_rates_num>200000) {
//            rabbitAdmin.purgeQueue(queue1);
//            log.info(queue1 + "队列清空");
//        }
//        if(callback_rates_28079763_num>200000) {
//            rabbitAdmin.purgeQueue(queue2);
//            log.info(queue2 + "队列清空");
//        }
//    }
//}
